import request from '@/utils/request'

// 查询单证列表
export function listDocument(query) {
  return request({
    url: '/fiscale/document/list',
    method: 'get',
    params: query
  })
}

// 查询单证详细
export function getDocument(documentId) {
  return request({
    url: '/fiscale/document/' + documentId,
    method: 'get'
  })
}

// 新增单证
export function addDocument(data) {
  return request({
    url: '/fiscale/document',
    method: 'post',
    data: data
  })
}

// 修改单证
export function updateDocument(data) {
  return request({
    url: '/fiscale/document',
    method: 'put',
    data: data
  })
}

// 删除单证
export function deleteDocument(documentId) {
  return request({
    url: '/fiscale/document/' + documentId,
    method: 'delete'
  })
}

// 上传单证
export function uploadDocument(data) {
  return request({
    url: '/fiscale/document/upload',
    method: 'post',
    data: data
  })
}

// 批量添加单证关联
export function batchAddDocumentRelations(documentId, relatedDocumentIds) {
  return request({
    url: '/fiscale/documentRelation/batchAdd/' + documentId,
    method: 'post',
    data: relatedDocumentIds
  })
}

// 查询单证的关联单证列表
export function getRelatedDocuments(documentId) {
  return request({
    url: '/fiscale/documentRelation/related/' + documentId,
    method: 'get'
  })
}